package editor;
public class Migrate {
	public static void main(String[] args) {
		File f = new File("sql")
		FileWriter fw = new FileWriter(f, true)
		for (int j = 5; j <= 37; j++) {
		InputStream is = getClass().getResourceAsStream("foods${j}")

		Scanner reader = new Scanner(is);
		String prefix = "insert into fc.Food (name, calorie, protein, carbohydrate, fat, fiber, foodgroup_id, quantity, unitofmeasurement_id, user_id) values ("
		String suffix = ",${j}, 100, 1, 1); "
		int lineNumber = 0
		while (reader.hasNextLine()) {
			try {
				lineNumber++
				String line = reader.nextLine()
				String[] subs = line.split("\t")
				String sub1 = subs[1].split(" / ")[1]
				String sb = "'${subs[0]}'"
				for (int i = 1; i < subs.length; i++) {
					if (i == 1) {
						sb += ',' + sub1.replaceAll(",", ".")
					if (subs[i] == '-') {
						subs[i] = '0'
					}
					} else {
						sb += ',' + subs[i].replaceAll(",", ".")
					}
				}

				String result = prefix + sb + suffix
				println result
				fw.write(result)
			} catch (Exception ex) {
			}
		}
		}
	}
}